{% extends 'base.html' %}

{% block title %}通知 - AI故事生成系统{% endblock %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-md-8 mx-auto">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h2 class="card-title mb-0">我的通知</h2>
                    {% if notifications %}
                    <form method="post" action="{% url 'interactive:notification_read_all' %}">
                        {% csrf_token %}
                        <button type="submit" class="btn btn-sm btn-outline-primary">全部标记为已读</button>
                    </form>
                    {% endif %}
                </div>
                <div class="card-body">
                    {% if notifications %}
                    <div class="list-group">
                        {% for notification in notifications %}
                        <div class="list-group-item {% if not notification.is_read %}list-group-item-primary{% endif %}">
                            <div class="d-flex justify-content-between align-items-center">
                                <div>
                                    <p class="mb-1">{{ notification.content }}</p>
                                    <small class="text-muted">{{ notification.created_at|date:"Y-m-d H:i" }}</small>
                                </div>
                                {% if not notification.is_read %}
                                <form method="post" action="{% url 'interactive:notification_read' notification.pk %}">
                                    {% csrf_token %}
                                    <button type="submit" class="btn btn-sm btn-outline-secondary">标记为已读</button>
                                </form>
                                {% endif %}
                            </div>
                            {% if notification.related_story %}
                            <div class="mt-2">
                                <a href="{% url 'story:detail' notification.related_story.pk %}" class="btn btn-sm btn-outline-primary">查看故事</a>
                            </div>
                            {% endif %}
                        </div>
                        {% endfor %}
                    </div>
                    {% else %}
                    <div class="alert alert-info">
                        暂无通知
                    </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 